package com.zz.hhbl.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.zz.hhbl.utils.LocationAlarmManager


/**
 * Copyright © 2025 zhun All rights reserved.
 * Created by ZhaoZhun on 2025/3/4 11:35.
 * @author: ZhaoZhun 1820022519@qq.com
 * @version: V1.0
 */
// 自定义广播接收器类，用于监听开机、关机事件
class SystemStatusReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val action = intent.action
        if (action != null) {
            when (action) {
                Intent.ACTION_BOOT_COMPLETED -> {
                    //AlarmManager 任务在 设备重启后会丢失，需要监听 BOOT_COMPLETED 事件：
                    LocationAlarmManager.startUpdateAlarm()
                    Log.d(TAG, "系统启动完成，执行相应操作")
                }
                Intent.ACTION_SHUTDOWN -> {
                    Log.d(TAG, "系统正在关闭，执行相应操作")
                }
            }
        }
    }
    companion object {
        private const val TAG = "SystemStatusReceiver"
    }
}